  function xp=myprctile(x,pvec); 
% function xp=myprctile(x,pvec); 
% 
% MY PERCENTILE 
% Compute the percentiles of the matrix X (txn) 
% For the percentiles pvec (0,1) 
% Output xp, percentiles per column 
% 
% Alejandro Justiniano 6/10/04 
% ajustiniano@imf.org 
% ===========================================
if nargin < 2; 
    error('Need define a vector of percentiles'); 
end; 
if any( pvec < eps)==1 | any( pvec > 1 )==1  
    error('Percentiles must be between 0 and 1') 
end 
x=x(:); 
[t,n]=size(x); 
x=sort(x); 
pvec=round(t*(sort( pvec(:) )) );
if pvec(1) < 1 | pvec(end) > t; 
    error('Percentiles exceed sample'); 
end 
xp=x(pvec,:); 

